package com.neuedu.hw_20190215;

import java.util.Scanner;

public class Hw07 {
    public static void main(String[] args) {

        /**
         * 分别在控制台输入字符串和子字符串，并计算字符串中子字符串出现的次数。
         */
        num();
    }

    public static void num(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入总字符串：");
        String str0 = scanner.next();
        System.out.println("请输入子字符串：");
        String str1 = scanner.next();

        int count=0;
        for (int i = 0; i < str0.length()-str1.length(); i=str0.indexOf(str1,i)+1) {
            if (str0.indexOf(str1,i)!=-1){
                count++;
            }
        }
        System.out.println(count);
    }
}
